package com.hh.servlet.custom;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.hh.dao.CustomDAO;

/**
 * Servlet implementation class CustomSave
 */
@WebServlet("/CustomSave")
public class CustomSave extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CustomSave() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String now = System.currentTimeMillis()+"";
        String no = now.substring(4,now.length());
		String HYKH = "HY"+no;
		String HYXM = request.getParameter("HYXM");
		String HYXB = request.getParameter("HYXB");
		String LXDH = request.getParameter("LXDH");
		String BLRQ = request.getParameter("BLRQ");
		String BLRY = request.getParameter("BLRY");
		String SZMD = request.getParameter("SZMD");
		CustomDAO dao = new CustomDAO();
		dao.insert(HYKH, HYXM, HYXB, LXDH, BLRQ, BLRY, SZMD);
		JSONObject obj = new JSONObject();
		obj.put("status", "success");
		response.getWriter().print(obj.toString());
		
	}

}
